<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="crm.model.Recepit"%>
<%@page import="crm.control.RecepitControl"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="crm.model.Offer"%>
<%@page import="crm.control.OfferControl"%>
<%@page import="crm.model.Employees"%>
<%@page import="crm.model.Purchase"%>
<%@page import="crm.control.PurchaseControl"%>
<%@page import="java.util.Collection"%>
<%@page import="java.util.Iterator"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../resources/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../resources/css/inner.css" type="text/css" media="screen" />
<style type='text/css'>
 a{font-size:12px; text-decoration:none; color:#70B300;}
</style>
<title>报价详情</title>
</head>
<body style='height:350px;'>
<%
            System.out.print("dsf");
            int offerId = ParamUtil.getInt(request,"id",0);
            Offer offer = OfferControl.getOfferById(offerId);
            System.out.print(offerId);
            Recepit recepit = RecepitControl.getRecepitByOfferId(offerId);
            Employees cu = (Employees)session.getAttribute("user");
            System.out.print(recepit.getId());
%>
<form>
<table>
<tr><td>报价主题</td><td><%=offer.getTheme() %></td></tr>
<tr><td>关联跟单</td><td><%=RecepitControl.getRecepitById(offer.getRecepit_id()).getTitle() %></td></tr>
<tr><td>报价金额</td><td><%=offer.getOffer_money() %></td></tr>
<tr><td>报价协商人</td><td><%=offer.getManager() %></td></tr>
<tr><td>报价时间</td><td><%=offer.getDate() %></td></tr>
  <%
            String p[] = RecepitControl.getRecepitById(offer.getRecepit_id()).getPrduct().split("@");
       %>
       </table>
       <p class='title'>产品</p>
       <table>
       <tr><td>天成软件</td><td><%=p[1] %></td> </tr>
       <tr><td>第三方软件</td><td><%=p[2] %></td> </tr>
       <tr><td>相关硬件</td><td><%=p[3] %></td> </tr>
<tr><td>状态</td><td><%if(offer.getState().equals("0")) out.print("待审核");if(offer.getState().equals("1")) out.print("审核通过");if(offer.getState().equals("2")) out.print("未通过"); %></td></tr>
</table>
</form>
<p class='title'>相关采购记录</p>
<form>
<table>
<tr><td>物品名称</td>
      <td>总支出</td>
      <td>采购数量</td>
      <td>单价</td>
      <td>商家</td>
      <td>购买人</td>
</tr>
<%
         Collection  ps = PurchaseControl.searchPurchase(String.valueOf(RecepitControl.getRecepitById(offer.getRecepit_id()).getId()),"","","","",1,100);
         Iterator itps = ps.iterator();
         while(itps.hasNext()){
        	 Purchase pu = (Purchase)itps.next();
        	 %>
        	 <tr><td><%=pu.getGoods_name() %></td>
        	 <td><%=pu.getSum_fee() %></td>
        	 <td><%=pu.getGoods_num() %></td>
        	 <td><%=pu.getSingle_price() %></td>
        	 <td><%=pu.getSeller() %></td>
        	 <td><%=pu.getPerson() %></td>
        	 </tr>
        	 <%
         }
%>
</table>
</form>
<p class='title'>
<%if(cu!=null&&(cu.getId()==RecepitControl.getRecepitById(offer.getRecepit_id()).getCurrent_person()||(cu.getPosition()!=1))){ 
        	 if(offer.getState().equals("2")){
%>
<a class='button' href="../recepit/turn_to_offer.jsp?id=<%=recepit.getId() %>">重新报价</a>&nbsp;&nbsp;&nbsp;&nbsp;
<%
        	 }
             if(offer.getState().equals("1")){
            	 if(RecepitControl.getRecepitById(offer.getRecepit_id()).getStage()==4){
%>
           <a class='button' href="turn_to_bargain.jsp?id=<%=offerId %>">转入合同</a>&nbsp;&nbsp;&nbsp;&nbsp;
            <%}
             } else{
            	 if(cu.getPosition()!=1){%>
	       <a class='button' href="control_to_offer.jsp?id=<%=offerId %>&&state=1">通过报价</a>&nbsp;&nbsp;&nbsp;&nbsp;
	        
	        <a href="control_to_offer.jsp?id=<%=offerId %>&&state=2" class='button'>不通过</a>
	        <%}}%>
	        </p> 
<%} %>
</body>
</html>